USE master;
GO

-- Habilitar o Service Broker no banco de dados AdventureWorks
ALTER DATABASE AdventureWorks SET ENABLE_BROKER;

-- Configurar o banco de dados AdventureWorks
USE AdventureWorks
GO
IF NOT EXISTS (SELECT * FROM sys.symmetric_keys WHERE name = '##MS_DatabaseMasterKey##')
CREATE MASTER KEY ENCRYPTION BY PASSWORD = '23987hxJ#KL95234nl0zBe';
GO

CREATE SCHEMA EMail
GO

-- Criar uma tabela para registrar detalhes dos emails do cliente enviados
CREATE TABLE EMail.EmailLog
(
    Date datetime NOT NULL,
    [Event] nvarchar(50) NOT NULL,
    CustomerData xml
)

